﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogicProgram
{
    public interface ILogger
{
		void Log (string message);
        
}

public class FileLogger : ILogger
{

public void Log (string message)
{
    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:/Лабы по ИС/lab4/Log.txt", true))
    {
        file.WriteLine(DateTime.Now + " " + message);
    }
}
}

public class ConsoleLogger : ILogger
{
    List<string> ILoggerConsole=new List<string>();
public void Log (string message)
{
	ILoggerConsole.Add(message);
}
public string WriteLog()
{
    string _log="";
   // Console.WriteLine();
   // Console.WriteLine("Log:");
    for (int i = 0; i < ILoggerConsole.Count; i++)
        _log+=ILoggerConsole[i]+Environment.NewLine;
    //Console.WriteLine();
    return _log;
}
}
public class LoggerFactory
{
		public ILogger CreateLogger(int type)
{

    if (type == 1)
        return new ConsoleLogger();
    else
        return new FileLogger();
}
}

}
